tab <- table(d.pizza$driver, d.pizza$wine_delivered)
Phi(tab)
ContCoef(tab)
CramerV(tab)
TschuprowT(tab)
# just x and y
CramerV(d.pizza$driver, d.pizza$wine_delivered)
# data.frame
PairApply(d.pizza[,c("driver","operator","area")], CramerV, symmetric = TRUE)
# useNA is passed to table
PairApply(d.pizza[,c("driver","operator","area")], CramerV,
useNA="ifany", symmetric = TRUE)
d.frm <- d.pizza[,c("driver","operator","area")]
PairApply(d.frm[complete.cases(d.frm),], CramerV, symmetric = TRUE)
m <- as.table(matrix(c(2,4,1,7), nrow=2))
YuleQ(m)
YuleY(m)
# Bootstrap confidence intervals for Cramer's V
# http://support.sas.com/documentation/cdl/en/statugfreq/63124/PDF/default/statugfreq.pdf, p. 1821
tab <- as.table(rbind(
c(26,26,23,18, 9),
c( 6, 7, 9,14,23)))
d.frm <- Untable(tab)
n <- 1000
idx <- matrix(sample(nrow(d.frm), size=nrow(d.frm) * n, replace=TRUE), ncol=n, byrow=FALSE)
v <- apply(idx, 2, function(x) CramerV(d.frm[x,1], d.frm[x,2]))
quantile(v, probs=c(0.025,0.975))
# compare this to the analytical ones
CramerV(tab, conf.level=0.95)
Run the code above in your browser using DataLab